//
// Created by hjie on 23-8-6.
//

#include "message_process.h"

MessageProcess::MessageProcess()
{

}

MessageProcess::MessageProcess(StunServer *server)
{
    m_stun_server = server;
}

void MessageProcess::ProcessRequest(StunMessage &message, WriteBuffer & buffer)
{
    StunMessage response;
    response.SetMsgType(EmBindResponse);
    response.m_transaction_id = message.m_transaction_id;
    response.m_magic_cookie   = message.m_magic_cookie;
    auto attr = message.m_attr_map;
    for (auto & data : attr)
    {
        if (data.first == EmXorMappedAddress)
        {
            // response.GetMsgAttr()[data.first] = data.second;
            response.AddStunAttr(data.second);
        }
    }
    response.ComposeStunPacket(buffer);
}